/*
 * Copyright [2013-2021], Alibaba Group Holding Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.alibaba.polardbx.util.bloomfilter;

import com.google.common.hash.HashCode;

import javax.annotation.concurrent.NotThreadSafe;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

@NotThreadSafe

public interface TddlHasher {
    TddlHasher putByte(byte b);

    default TddlHasher putBytes(byte[] bytes) {
        return putBytes(bytes, 0, bytes.length);
    }

    TddlHasher putBytes(byte[] bytes, int off, int len);

    TddlHasher putBytes(ByteBuffer bytes);

    default TddlHasher putShort(short s) {
        return putLong(s);
    }

    default TddlHasher putInt(int i) {
        return putLong(i);
    }

    TddlHasher putLong(long l);

    TddlHasher putDouble(double d);

    TddlHasher putBoolean(boolean b);

    TddlHasher putChar(char c);

    default TddlHasher putString(String input) {

        return putBytes(input.getBytes(StandardCharsets.UTF_8));
    }

    HashCode hash();

    @Override
    @Deprecated
    int hashCode();
}
